import isValid from '@/js/isValid'

var passwordCheck = (rule, value, callback) => {
    if (value === "") {
      callback();
      
    }else if(value===null){
      callback();
    }
     else if (!isValid.isvalidPass(value)) {
      callback(
        new Error("密码长度在6~18之间 只能包含字母、数字和下划线")
      );
    } else {
      // if (this.formData.repassword !== "") {
      //   this.$refs.ruleForm.validateField("repassword");
      // }
      callback();
    }
  };
  var phoneCheck = (rule, value, callback) => {

    if(value===''){
      callback();
    }else if(value===null){
      callback();
    }
    else if (!isValid.isvalidPhone(value)) {
      callback(new Error("请填写正确的手机号码"));
    }else{
      callback();
    }
  };

  var usernameCheck = (rule, value, callback) => {
    if (value === "") {
      callback(new Error("请输入用户名"));
  
    } else if (!isValid.isvalidUsername(value)) {
      callback(
        new Error(
          "用户名要求数字或者字母长度为3-10个字符"
        )
      );
    }else{
      callback();
    }
  };
 export default{
  passwordCheck,phoneCheck,usernameCheck
 }

